package com.neueedu.android;

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MainActivityBack extends AppCompatActivity  implements View.OnClickListener {


    Button btnConcat ;
    Button btnAccount ;
    Button btnPassword ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        setContentView(R.layout.activity_main_back);

        btnConcat =  findViewById(R.id.btnConcat);
        btnAccount = findViewById(R.id.btnAccount);
        btnPassword = findViewById(R.id.btnPassword);


        //第三种写法
        btnConcat.setOnClickListener(this);
        btnAccount.setOnClickListener(this);
        btnPassword.setOnClickListener(this);



        //第二种写法 内部类MyOnClickListener

//        btnConcat.setOnClickListener(new MyOnClickListener());
//        btnAccount.setOnClickListener(new MyOnClickListener());
//        btnPassword.setOnClickListener(new MyOnClickListener());



        //第一种写法
//        btnConcat.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                Intent intent = new Intent(MainActivity.this, ConcatActivity.class);
//
//                startActivity(intent);
//            }
//        });
//
//        btnAccount.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                Intent intent = new Intent(MainActivity.this, MyAccountActivity.class);
//
//                startActivity(intent);
//            }
//        });
//
//        btnPassword.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                Intent intent = new Intent(MainActivity.this, PasswordActivity.class);
//
//                startActivity(intent);
//            }
//        });



//        Intent intent = getIntent();
//        CharSequence username = intent.getCharSequenceExtra("username");
//        CharSequence password = intent.getCharSequenceExtra("password");
//
//        System.out.println("===onCreate====");
//
//        Log.v("MainActivity","==onCreate===");
//        Log.v("MainActivity","==username===:"+username);
//        Log.v("MainActivity","==password===:"+password);
      ;

    }



    @Override
    protected void onStart() {
        super.onStart();
        System.out.println("===onStart====");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.v("MainActivity","==onResume===");
    }


    @Override
    protected void onRestart() {
        super.onRestart();
        Log.v("MainActivity","==onRestart===");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.v("MainActivity","==onPause===");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.v("MainActivity","==onStop===");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.v("MainActivity","==onDestroy===");

    }

    @Override
    public void onClick(View view) {
        Class targetClass = null;
        switch (view.getId()){
            case  R.id.btnConcat:
                targetClass = ConcatActivity.class;
                break;
            case  R.id.btnAccount:
                targetClass = MyAccountActivity.class;
                break;
            case  R.id.btnPassword:
                targetClass = PasswordActivity.class;
                break;
        }


        Intent intent = new Intent(MainActivityBack.this,targetClass);
        startActivity(intent);
    }


    class MyOnClickListener implements View.OnClickListener{

        @Override
        public void onClick(View view) {

            Class targetClass = null;
            switch (view.getId()){
                case  R.id.btnConcat:
                    targetClass = ConcatActivity.class;
                    break;
                case  R.id.btnAccount:
                    targetClass = MyAccountActivity.class;
                    break;
                case  R.id.btnPassword:
                    targetClass = PasswordActivity.class;
                    break;
            }


            Intent intent = new Intent(MainActivityBack.this,targetClass);
            startActivity(intent);
        }
    }



}
